import { stringify } from 'qs';
import request from '@/utils/request';
import { paramsToFormData, removeProperty } from '@/utils/utils';

export async function getCompetitionList(params) {
  return request(`/api/competition/getCompetitionList?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getCurrentCompetitionDetail() {
  return request(`/api/competition/getCurrentCompetitionDetail`, {
    method: 'GET',
  });
}

export async function getCompetitionDetail(params) {
  return request(`/api/competition/getCompetitionDetail?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getAdvertisePicture(params) {
  return request(`/api/competition/getAdvertisePicture?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getSignUpInfo() {
  return request(`/api/competition/getSignUpInfo`, {
    method: 'GET',
  });
}

export async function deleteAdvertisePicture(params) {
  return request(`/api/competition/deleteAdvertisePicture?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getCurrentCompetition() {
  return request('/api/competition/getCurrentCompetition', {
    method: 'GET',
  });
}

export async function getCompetitionInformation() {
  return request('/api/competition/getCompetitionInformation', {
    method: 'GET',
  });
}

export async function getContact() {
  return request('/api/competition/getContact', {
    method: 'GET',
  });
}
export async function getOrganizer() {
  return request('/api/competition/getOrganizer', {
    method: 'GET',
  });
}

export async function getExaminationPaper() {
  return request('/api/competition/getExaminationPaper', {
    method: 'GET',
  });
}

export async function getUserExaminationPaper(params) {
  return request(`/api/competition/getUserExaminationPaper?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getExaminationColumn(params) {
  return request(`/api/competition/getExaminationColumn?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getExaminationQuestion(params) {
  return request(`/api/competition/getExaminationQuestion?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getEnrollList() {
  return request(`/api/competition/getEnrollList`, {
    method: 'GET',
  });
}

export async function getUploadAnswer(params) {
  return request(`/api/competition/getUploadAnswer?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getCompetitionReviewList() {
  return request(`/api/competition/getCompetitionReviewList`, {
    method: 'GET',
  });
}

export async function getEnrollUser(params) {
  return request(`/api/competition/getEnrollUser?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getScore(params) {
  return request(`/api/competition/getScore?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getGradeTeacher() {
  return request(`/api/competition/getGradeTeacher`, {
    method: 'GET',
  });
}

export async function getCharts(params) {
  return request(`/api/competition/getCharts?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function getTeacherGrade(params) {
  return request(`/api/competition/getTeacherGrade?${stringify(params)}`, {
    method: 'GET',
  });
}



// ----------------------------------------------------------------------

export async function newCompetition() {
  return request('/api/competition/newCompetition', {
    method: 'POST',
  });
}

export async function deleteCompetition(params) {
  return request('/api/competition/deleteCompetition', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function setCurrentCompetition(params) {
  return request('/api/competition/setCurrentCompetition', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function setFillItem(params) {
  return request('/api/competition/fillItem', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}
export async function setSingleOption(params) {
  return request('/api/competition/singleOption', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}
export async function setDoubleOption(params) {
  return request('/api/competition/doubleOption', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function deleteOption(params) {
  return request('/api/competition/deleteOption', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function setCompetitionInformation(params) {
  return request('/api/competition/setCompetitionInformation', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}
export async function setContact(params) {
  const res = removeProperty(params)
  return request('/api/competition/setContact', {
    method: 'POST',
    body: paramsToFormData(res)
  });
}
export async function setOrganizer(params) {
  const res = removeProperty(params)
  return request('/api/competition/setOrganizer', {
    method: 'POST',
    body: paramsToFormData(res)
  });
}

export async function setExamPaper(params) {
  const res = removeProperty(params)
  return request('/api/competition/setExamPaper', {
    method: 'POST',
    body: paramsToFormData(res)
  });
}

export async function createExamColumn(params) {
  return request('/api/competition/createExamColumn', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function setExamColumn(params) {
  const res = removeProperty(params)
  return request('/api/competition/setExamColumn', {
    method: 'POST',
    body: paramsToFormData(res)
  });
}

export async function setExamQuestion(params) {
  delete params.keys;
  return request('/api/competition/setExamQuestion', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function deleteExamQuestion(params) {
  const res = removeProperty(params)
  return request('/api/competition/deleteExamQuestion', {
    method: 'POST',
    body: paramsToFormData(res)
  });
}

export async function deleteExamColumn(params) {
  const res = removeProperty(params)
  return request('/api/competition/deleteExamColumn', {
    method: 'POST',
    body: paramsToFormData(res)
  });
}

export async function publishCompetition(params) {
  return request('/api/competition/publishCompetition', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function reEditCompetition(params) {
  return request('/api/competition/reEditCompetition', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function createExamQuestion(params) {
  const res = removeProperty(params)
  return request('/api/competition/createExamQuestion', {
    method: 'POST',
    body: paramsToFormData(res)
  });
}

export async function enrollCompetition(params) {
  return request('/api/competition/enrollCompetition', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function setScore(params) {
  return request('/api/competition/setScore', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function setGradeTeacher(params) {
  return request('/api/competition/setGradeTeacher', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

export async function endCompetition(params) {
  return request('/api/competition/endCompetition', {
    method: 'POST',
    body: paramsToFormData(params)
  });
}

// export async function enrollCompetitionMessage(params) {
//   console.log(params)
//   return request('/api/competition/enrollCompetitionMessage', {
//     method: 'POST',
//     body: stringify(params)
//   });
// }

